<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>比特币的原理 | 麦甜怪圈 Xiaomai Circle</title><meta name="author" content="小麦 Andrew Xiaomai"><meta name="copyright" content="小麦 Andrew Xiaomai"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="ffffff"><meta name="description" content="哈喽大家好！我是小麦。最近想装一台电脑，然后看了眼显卡价格……嗯，还是很高。想到了导致今天这个局面的“罪魁祸首”——加密货币。今天看了李永乐老师两年前讲解比特币原理的视频，现在来做个笔记。 老规矩，视频链接：  李永乐老师Youtube：https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v&#x3D;g_fSistU3MQ 李永乐老师BiliBili：https:&#x2F;&#x2F;www.bilibili.co">
<meta property="og:type" content="article">
<meta property="og:title" content="比特币的原理">
<meta property="og:url" content="https://kingsmai.github.io/2021/08/03/%E6%AF%94%E7%89%B9%E5%B8%81%E7%9A%84%E5%8E%9F%E7%90%86/index.html">
<meta property="og:site_name" content="麦甜怪圈 Xiaomai Circle">
<meta property="og:description" content="哈喽大家好！我是小麦。最近想装一台电脑，然后看了眼显卡价格……嗯，还是很高。想到了导致今天这个局面的“罪魁祸首”——加密货币。今天看了李永乐老师两年前讲解比特币原理的视频，现在来做个笔记。 老规矩，视频链接：  李永乐老师Youtube：https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v&#x3D;g_fSistU3MQ 李永乐老师BiliBili：https:&#x2F;&#x2F;www.bilibili.co">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://kingsmai.github.io/uploads/BlockChain.gif">
<meta property="article:published_time" content="2021-08-03T14:50:01.000Z">
<meta property="article:modified_time" content="2023-12-17T23:26:18.828Z">
<meta property="article:author" content="小麦 Andrew Xiaomai">
<meta property="article:tag" content="李永乐老师">
<meta property="article:tag" content="加密货币">
<meta property="article:tag" content="比特币">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://kingsmai.github.io/uploads/BlockChain.gif"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://kingsmai.github.io/2021/08/03/%E6%AF%94%E7%89%B9%E5%B8%81%E7%9A%84%E5%8E%9F%E7%90%86/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: {"limitDay":365,"position":"top","messagePrev":"这篇文章已经","messageNext":"天未被更新了，可能里边的内容已经过时，请注意斟酌。"},
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: 小麦 Andrew Xiaomai","link":"链接: ","source":"来源: 麦甜怪圈 Xiaomai Circle","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体中文","cht_to_chs":"你已切换为简体中文","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"bottom-left"},
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: true,
  islazyload: false,
  isAnchor: true,
  percent: {
    toc: true,
    rightside: true,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '比特币的原理',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-12-18 07:26:18'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', 'ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          const now = new Date()
          const hour = now.getHours()
          const isNight = hour <= 6 || hour >= 18
          if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
          else if (t === 'light') activateLightMode()
          else activateDarkMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><link rel="stylesheet" href="https://at.alicdn.com/t/c/font_4366094_hx3hbrje2st.css"><meta name="generator" content="Hexo 7.0.0"><link rel="alternate" href="/atom.xml" title="麦甜怪圈 Xiaomai Circle" type="application/atom+xml">
<link rel="alternate" href="/rss2.xml" title="麦甜怪圈 Xiaomai Circle" type="application/rss+xml">
</head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://avatars.githubusercontent.com/u/23566051?s=400&amp;u=cc8834557b9fe7ca3db3adc89606ae47503e603d&amp;v=4" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">37</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">28</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fa-fw fas fa-list"></i><span> 列表</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/uploads/BlockChain.gif')"><nav id="nav"><span id="blog-info"><a href="/" title="麦甜怪圈 Xiaomai Circle"><img class="site-icon" src="/img/logos/Logo-11.jpg"/><span class="site-name">麦甜怪圈 Xiaomai Circle</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fa-fw fas fa-list"></i><span> 列表</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);" rel="external nofollow noreferrer"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">比特币的原理</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-08-03T14:50:01.000Z" title="发表于 2021-08-03 22:50:01">2021-08-03</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-12-17T23:26:18.828Z" title="更新于 2023-12-18 07:26:18">2023-12-18</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF/">技术</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF/%E5%8C%BA%E5%9D%97%E9%93%BE/">区块链</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">2.2k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>6分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="比特币的原理"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><p>哈喽大家好！我是小麦。最近想装一台电脑，然后看了眼显卡价格……嗯，还是很高。想到了导致今天这个局面的“罪魁祸首”——加密货币。今天看了李永乐老师两年前讲解比特币原理的视频，现在来做个笔记。</p>
<p>老规矩，视频链接：</p>
<ol>
<li>李永乐老师Youtube：<a target="_blank" rel="noopener external nofollow noreferrer" href="https://www.youtube.com/watch?v=g_fSistU3MQ">https://www.youtube.com/watch?v=g_fSistU3MQ</a></li>
<li>李永乐老师BiliBili：<a target="_blank" rel="noopener external nofollow noreferrer" href="https://www.bilibili.com/video/av45247943">https://www.bilibili.com/video/av45247943</a></li>
<li>老高与小茉比特币：<a target="_blank" rel="noopener external nofollow noreferrer" href="https://www.youtube.com/watch?v=7B-1vDFuYRk">https://www.youtube.com/watch?v=7B-1vDFuYRk</a></li>
<li>老高与小茉区块链：<a target="_blank" rel="noopener external nofollow noreferrer" href="https://www.youtube.com/watch?v=sjx_rpay9rk">https://www.youtube.com/watch?v=sjx_rpay9rk</a></li>
</ol>
<p>以下文章可能有点深奥，读者可以在文章下方讨论，我会尝试给你们解答。</p>
<h2 id="比特币是什么"><a href="#比特币是什么" class="headerlink" title="比特币是什么"></a>比特币是什么</h2><p>比特币也叫电子货币、数字货币，它由一名化名为中本聪的网络极客于2008年11月1日在网络上写的一篇文章《比特币：一种点对点的电子现金系统》所提出。这篇文这里提出一种构思：<strong>去中心化</strong>的电子<strong>记账</strong>系统。</p>
<p><img src="/uploads/BitCoin%2016.png"/></p>
<h3 id="去中心化的电子记账系统"><a href="#去中心化的电子记账系统" class="headerlink" title="去中心化的电子记账系统"></a>去中心化的电子记账系统</h3><p>我们在和别人进行交易之后，需要检查我还有多少余额，这就是记账。目前我们的记账包括使用电子钱包都是由银行来记账。 银行就是这套记账系统的中心，我们信任银行，因为银行的背后是国家的信用。</p>
<p>而比特币是去中心化的记账系统。</p>
<h2 id="怎么去中心化"><a href="#怎么去中心化" class="headerlink" title="怎么去中心化"></a>怎么去中心化</h2><p>去掉银行、微信支付宝这些可信任的第三方之后，最大的问题是我们无法互相信任。中本聪提到的概念是：将所有人的账本都公开给别人看。在区块链的世界，转账就得发广播，目的就是让所有人都知道网络里每个人每一笔钱的来龙去脉。</p>
<p>当 A 和 B 进行交易，A 需要把交易信息和电子签名告诉所有这个系统下的用户（广播）。大家会通过电子签名验证这句话的确是 A 说的，再将这笔帐记载账本上。</p>
<p>那么大家怎么知道 A 有这笔钱呢？A 的账本帮忙确认，而这个账本就叫做区块。</p>
<h2 id="区块链-BlockChain"><a href="#区块链-BlockChain" class="headerlink" title="区块链 BlockChain"></a>区块链 BlockChain</h2><p>比特币的底层技术就是区块链。</p>
<p>这些由不同人发出的账单需要打包成一个块，称之为区块。一个区块的大小大概是1Mb，大约能储存4000条交易信息，取决于每条信息长度。</p>
<p>这个区块要和以前的区块（从比特币诞生的第一个区块一直到上一个区块）连在一起，再把新的区块往后接，这就叫做区块链。</p>
<p>区块链记录了比特币从创立到今天每一笔交易记录，所有人的钱从哪来到哪去都记得一清二楚、透明公开。</p>
<p><img src="/uploads/BlockChain.gif" alt="区块链示意图"/></p>
<h2 id="遇到几个问题"><a href="#遇到几个问题" class="headerlink" title="遇到几个问题"></a>遇到几个问题</h2><p>有了系统之后，我们需要思考几个问题：以谁为准？为什么别人愿意帮你记账？怎么防伪、篡改？怎么防止双重支付？怎么保密？</p>
<h3 id="记账的动力"><a href="#记账的动力" class="headerlink" title="记账的动力"></a>记账的动力</h3><p>为什么别人愿意消耗自己的电脑资源去记录和他自己无关的账单？为了让所有人有动力去做题记账，比特币有个奖励系统：</p>
<ol>
<li>手续费。每个人在进行交易的时候都需要多付一点比特币，多付的钱就作为记账的手续费。这和平时我们用银行卡、信用卡的手续费是一样的。甚至银行卡的手续费来的更高。</li>
<li>打包奖励。中本聪提出一个方案：从比特币创建之初，每过 10 分钟需要打包一个区块，每个区块奖励 50 比特币（只有其中一个用户有权利打包），然后每隔四年，奖励减半。</li>
</ol>
<p>根据打包奖励，我们可以算出总共有多少个比特币：</p>
<p>一个包50比特币，<br>一个小时6个10分钟，<br>每天24小时，<br>每年365天，<br>奖励减半周期为4年。</p>
<p>50 × 6 × 24 × 365 × 4 × ( 1 + ½ + ½2 + ½3 + …) = 2100万</p>
<h3 id="以谁为准"><a href="#以谁为准" class="headerlink" title="以谁为准"></a>以谁为准</h3><p>每个人都想要这笔奖励，所有每个人都抢着去打包。每个区块里的包含的交易和交易顺序都会不同，如果有记假账的那就更混乱了。所以，记账者必须让所有人都能接受，这样大家的账本才能统一，这也被称为共识机制（Consensus mechanism）。中本聪的办法是“工作量证明（Proof of Work）“，它的本质是穷举。每个人都需要去做一个很难的数学题。这个很难的数学题是没人可以用脑子计算出来的，必须一个一个数去尝试，才能试出结果。这个过程称之为：挖矿。</p>
<p>如果有人把这个数学题做出来了，那就可以获得打包奖励。</p>
<h3 id="挖矿"><a href="#挖矿" class="headerlink" title="挖矿"></a>挖矿</h3><p>那么这道数学题是怎样的数学题呢？这里提到一个算法——哈希函数。我会另外写一篇文章研究这个。哈希函数主要是把一个字符串（数据）运算之后转换成摘要的形式。而且正向算很容易，反向推导却很难（几乎不可能）。</p>
<p>其中一个很著名的算法叫 SHA256，是美国国家安全局发明的一种算法。具体就是将数据经过算法之后变为一个独一无二的 256 位二进制数。不管你的数据长度多少，最后生成出来的二进制数一定是 256 位，而原输入只要有一点轻微改动，也会导致每一位数值产生变化。</p>
<p>挖矿就是基于 SHA256 的运算。我们需要对一个字符串进行两次 SHA256 计算。</p>
<p>打开一个区块（通常是个JSON文件）可以看到里面包含了：</p>
<ol>
<li>头部信息（区块头）</li>
<li>交易数量 Number of transactions</li>
<li>交易详情 Transaction details</li>
</ol>
<p><img src="/uploads/BlockChain.gif" alt="区块链示意图"/></p>
<p>区块头是区块的标签，里面包含：</p>
<ol>
<li>时间戳<br>该区块产生的近似时间，精确到秒的UNIX时间戳，必须严格大于前11个区块时间的中值，同时全节点也会拒绝那些超出自己 2 个小时时间戳的区块</li>
<li>Merkle根<br>该区块中，交易的Merkle树根的哈希值（同样采用两次 SHA256 进行计算）</li>
<li>随机数<br>为了找到<strong>满足目标所设定的随机数</strong></li>
<li>上一个区块的哈希值。</li>
</ol>
<p>在这里，我们把区块头理解为字符串。</p>
<h3 id="记账以及计算难度"><a href="#记账以及计算难度" class="headerlink" title="记账以及计算难度"></a>记账以及计算难度</h3><p>想要记账（将我们的区块链接上去），我们需要把字符串执行哈希加密，并且加密结果（也就是 256 位二进制数）的前面几位数必须为零（取决于当前设置难度）。那么字符串是不能改的，因为里面包含了所有的区块信息，唯一能改的是区块头里的随机数。</p>
<p>二进制只有两种可能 0 或 1，所以进行一次哈希加密的成功率等于 2 的 n 次方分之一。而这个 n 就是所需要的（前几位）0，取决于当前参与计算的算力，算力越强，要算的 0 越多 PoW 的证明难度也就越大。</p>
<p>当然，每个人的打包难度都是不一样的，影响因素有：交易信息、时间戳、个人信息。所以照成随机数大小不同（前面说了随机数只能通过穷举的方式进行计算）。有的人运气好，第一个数就算出来了，有的人需要多算很多次。平均来说的话，就是<strong>谁的计算能力好，谁就更有希望打包这个块</strong>。</p>
<p>中本聪在设计的时候，保证<strong>每十分钟出一个块</strong>，所以需要改变 n 的难度，才能达成这个目标。这里我们做个数学题</p>
<ul>
<li>假设世界上有 10000 台矿机，每台矿机的计算量大概是 14T Hash/s，每秒计算 14T（T 是 1012） 所以是 1.4 × 1013</li>
<li>十分钟总共能计算： 1.4 × 1013 次 × 104 台 × 600 秒 = 8 × 1019 次。</li>
<li>概率是 1/2n 所以需要出一个块，平均计算的次数是 2n</li>
<li>通过计算，n = 66，所以概率 P = 1/266 。平均计算的次数是 266 大概等于 8 × 1019 次。</li>
</ul>
<p>那我们这里讲了比特币的底层架构（区块链）以及挖矿是什么东西。下一篇我们来研究比特币的安全性。</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://kingsmai.github.io">小麦 Andrew Xiaomai</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://kingsmai.github.io/2021/08/03/%E6%AF%94%E7%89%B9%E5%B8%81%E7%9A%84%E5%8E%9F%E7%90%86/">https://kingsmai.github.io/2021/08/03/比特币的原理/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="external nofollow noreferrer" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://kingsmai.github.io" target="_blank">麦甜怪圈 Xiaomai Circle</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E6%9D%8E%E6%B0%B8%E4%B9%90%E8%80%81%E5%B8%88/">李永乐老师</a><a class="post-meta__tags" href="/tags/%E5%8A%A0%E5%AF%86%E8%B4%A7%E5%B8%81/">加密货币</a><a class="post-meta__tags" href="/tags/%E6%AF%94%E7%89%B9%E5%B8%81/">比特币</a></div><div class="post_share"><div class="social-share" data-image="/uploads/BlockChain.gif" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i>欢迎打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/wallets/WechatPaySquare.jpg" target="_blank"><img class="post-qr-code-img" src="/img/wallets/WechatPaySquare.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/img/wallets/AlipaySquare.jpg" target="_blank"><img class="post-qr-code-img" src="/img/wallets/AlipaySquare.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2021/08/02/%E6%97%A5%E8%AE%B0%E5%8A%A0%E5%AF%86%E6%80%9D%E8%B7%AF%E6%80%BB%E7%BB%93/" title="日记加密思路总结"><img class="cover" src="/uploads/Diary%20Encrypt%20Step%204.gif" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">日记加密思路总结</div></div></a></div><div class="next-post pull-right"><a href="/2021/08/04/%E6%AF%94%E7%89%B9%E5%B8%81%E7%9A%84%E5%AE%89%E5%85%A8/" title="比特币的安全"><img class="cover" src="/uploads/BlockChain.gif" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">比特币的安全</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2021/08/04/%E6%AF%94%E7%89%B9%E5%B8%81%E7%9A%84%E5%AE%89%E5%85%A8/" title="比特币的安全"><img class="cover" src="/uploads/BlockChain.gif" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-08-04</div><div class="title">比特币的安全</div></div></a></div><div><a href="/2021/08/07/%E4%BB%80%E4%B9%88%E6%98%AF%E6%95%B0%E5%AD%97%E7%AD%BE%E5%90%8D/" title="什么是数字签名"><img class="cover" src="/uploads/Digital%20Signature.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-08-07</div><div class="title">什么是数字签名</div></div></a></div><div><a href="/2021/08/02/%E6%97%A5%E8%AE%B0%E5%8A%A0%E5%AF%86%E6%80%9D%E8%B7%AF%E6%80%BB%E7%BB%93/" title="日记加密思路总结"><img class="cover" src="/uploads/Diary%20Encrypt%20Step%204.gif" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-08-02</div><div class="title">日记加密思路总结</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://avatars.githubusercontent.com/u/23566051?s=400&amp;u=cc8834557b9fe7ca3db3adc89606ae47503e603d&amp;v=4" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">小麦 Andrew Xiaomai</div><div class="author-info__description">一个喜欢肉鸽类游戏的程序员<br>分享日常生活，学习笔记，技术文章等。感兴趣想一起开发游戏的欢迎联系我哟！</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">37</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">28</div></a></div><a id="card-info-btn" target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/kingsmai"><i class="fab fa-github"></i><span>关注我</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/kingsmai" rel="external nofollow noreferrer" target="_blank" title="Github"><i class="iconfont icon-GitHub" style="color: #24292e;"></i></a><a class="social-icon" href="https://space.bilibili.com/670118055" rel="external nofollow noreferrer" target="_blank" title="BiliBili"><i class="iconfont icon-bilibili-fill" style="color: #ff6699;"></i></a><a class="social-icon" href="mailto:xsbugh@gmail.com" rel="external nofollow noreferrer" target="_blank" title="Email"><i class="iconfont icon-email-fill" style="color: #ff3e30;"></i></a><a class="social-icon" href="https://www.zhihu.com/people/creeper0924" rel="external nofollow noreferrer" target="_blank" title="Zhihu"><i class="iconfont icon-zhihu" style="color: #1772F6;"></i></a><a class="social-icon" href="https://blog.csdn.net/Xsbugh" rel="external nofollow noreferrer" target="_blank" title="CSDN"><i class="iconfont icon-csdn" style="color: #FC4144;"></i></a><a class="social-icon" href="https://www.linkedin.com/in/%E5%B0%8F%E9%BA%A6-xiaomai-0a672124b/" rel="external nofollow noreferrer" target="_blank" title="LinkedIn"><i class="iconfont icon-linkedin" style="color: #0A66C2;"></i></a><a class="social-icon" href="/atom.xml" target="_blank" title="RSS 链接"><i class="iconfont icon-Atom" style="color: #6EA3E5;"></i></a><a class="social-icon" href="/rss2.xml" target="_blank" title="RSS 链接"><i class="iconfont icon-dingyue" style="color: #ee802f;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="card-widget"><div class="item-headline"><i></i><span></span></div><div class="item-content"></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%AF%94%E7%89%B9%E5%B8%81%E6%98%AF%E4%BB%80%E4%B9%88"><span class="toc-number">1.</span> <span class="toc-text">比特币是什么</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8E%BB%E4%B8%AD%E5%BF%83%E5%8C%96%E7%9A%84%E7%94%B5%E5%AD%90%E8%AE%B0%E8%B4%A6%E7%B3%BB%E7%BB%9F"><span class="toc-number">1.1.</span> <span class="toc-text">去中心化的电子记账系统</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%80%8E%E4%B9%88%E5%8E%BB%E4%B8%AD%E5%BF%83%E5%8C%96"><span class="toc-number">2.</span> <span class="toc-text">怎么去中心化</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8C%BA%E5%9D%97%E9%93%BE-BlockChain"><span class="toc-number">3.</span> <span class="toc-text">区块链 BlockChain</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%81%87%E5%88%B0%E5%87%A0%E4%B8%AA%E9%97%AE%E9%A2%98"><span class="toc-number">4.</span> <span class="toc-text">遇到几个问题</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B0%E8%B4%A6%E7%9A%84%E5%8A%A8%E5%8A%9B"><span class="toc-number">4.1.</span> <span class="toc-text">记账的动力</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BB%A5%E8%B0%81%E4%B8%BA%E5%87%86"><span class="toc-number">4.2.</span> <span class="toc-text">以谁为准</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8C%96%E7%9F%BF"><span class="toc-number">4.3.</span> <span class="toc-text">挖矿</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%B0%E8%B4%A6%E4%BB%A5%E5%8F%8A%E8%AE%A1%E7%AE%97%E9%9A%BE%E5%BA%A6"><span class="toc-number">4.4.</span> <span class="toc-text">记账以及计算难度</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2023/12/20/ML-8-%E6%9E%84%E5%BB%BA%E9%80%BB%E8%BE%91%E5%9B%9E%E5%BD%92%E6%A8%A1%E5%9E%8B/" title="Sololearn 自学机器学习（8）构建逻辑回归模型"><img src="/img/covers/sklearn-build-linear-regression-model.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Sololearn 自学机器学习（8）构建逻辑回归模型"/></a><div class="content"><a class="title" href="/2023/12/20/ML-8-%E6%9E%84%E5%BB%BA%E9%80%BB%E8%BE%91%E5%9B%9E%E5%BD%92%E6%A8%A1%E5%9E%8B/" title="Sololearn 自学机器学习（8）构建逻辑回归模型">Sololearn 自学机器学习（8）构建逻辑回归模型</a><time datetime="2023-12-19T16:15:57.000Z" title="发表于 2023-12-20 00:15:57">2023-12-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/12/19/ML-7-%E7%BA%BF%E6%80%A7%E5%9B%9E%E5%BD%92%E6%A8%A1%E5%9E%8B/" title="Sololearn 自学机器学习（7）线性回归模型"><img src="/img/covers/linear-regression-3.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Sololearn 自学机器学习（7）线性回归模型"/></a><div class="content"><a class="title" href="/2023/12/19/ML-7-%E7%BA%BF%E6%80%A7%E5%9B%9E%E5%BD%92%E6%A8%A1%E5%9E%8B/" title="Sololearn 自学机器学习（7）线性回归模型">Sololearn 自学机器学习（7）线性回归模型</a><time datetime="2023-12-19T08:07:36.000Z" title="发表于 2023-12-19 16:07:36">2023-12-19</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/12/19/ML-6-%E5%88%86%E7%B1%BB-Classification/" title="Sololearn 自学机器学习（6）分类 Classification"><img src="/img/covers/classifications-3.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Sololearn 自学机器学习（6）分类 Classification"/></a><div class="content"><a class="title" href="/2023/12/19/ML-6-%E5%88%86%E7%B1%BB-Classification/" title="Sololearn 自学机器学习（6）分类 Classification">Sololearn 自学机器学习（6）分类 Classification</a><time datetime="2023-12-19T05:36:19.000Z" title="发表于 2023-12-19 13:36:19">2023-12-19</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/12/19/ML-5-Matplotlib-%E7%BB%98%E5%9B%BE%E5%9F%BA%E7%A1%80/" title="Sololearn 自学机器学习（5）Matplotlib 绘图基础"><img src="/img/covers/matplotlib-plot-basic-5.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Sololearn 自学机器学习（5）Matplotlib 绘图基础"/></a><div class="content"><a class="title" href="/2023/12/19/ML-5-Matplotlib-%E7%BB%98%E5%9B%BE%E5%9F%BA%E7%A1%80/" title="Sololearn 自学机器学习（5）Matplotlib 绘图基础">Sololearn 自学机器学习（5）Matplotlib 绘图基础</a><time datetime="2023-12-18T17:08:34.000Z" title="发表于 2023-12-19 01:08:34">2023-12-19</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2023/12/18/ML-4-Numpy-%E6%95%B0%E6%8D%AE%E5%A4%84%E7%90%86/" title="Sololearn 自学机器学习（4）Numpy 数据处理"><img src="/img/covers/numpy-data-processing-2.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Sololearn 自学机器学习（4）Numpy 数据处理"/></a><div class="content"><a class="title" href="/2023/12/18/ML-4-Numpy-%E6%95%B0%E6%8D%AE%E5%A4%84%E7%90%86/" title="Sololearn 自学机器学习（4）Numpy 数据处理">Sololearn 自学机器学习（4）Numpy 数据处理</a><time datetime="2023-12-18T13:26:11.000Z" title="发表于 2023-12-18 21:26:11">2023-12-18</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('/uploads/BlockChain.gif')"><div id="footer-wrap"><div class="copyright">&copy;2019 - 2023 By 小麦 Andrew Xiaomai</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener external nofollow noreferrer" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener external nofollow noreferrer" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text"><a href="https://icp.gov.moe/?keyword=20235160" rel="external nofollow noreferrer" target="_blank"><img class="icp-icon" src="/img/moe-icons/icon120.png">备案号：✮萌ICP备20235160号✮</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><div class="js-pjax"></div><canvas class="fireworks" mobile="true"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/fireworks.min.js"></script><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-fluttering-ribbon.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div></body></html>